class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int n = 0;
        int cnt[200] = {0};
        int l = 0,r = 0,len = 0;
        for(auto c :s){
            while(cnt[c]){
                cnt[s[l]]--;
                l++;
            }
            cnt[c]++;
            len = max(len,r-l+1);
            r++;
        }
        return len;
    }
};